import React from 'react'
import {WeaSearchGroup, WeaFormItem, WeaTableEditable, WeaLocaleProvider} from "ecCom";
import {observable, action, toJS} from 'mobx';

const getLabel = WeaLocaleProvider.getLabel;

/**
 * 组装合同操作权限节点信息表
 */
class NodesTable extends React.Component {
    constructor(props) {
        super(props);
    }

    /**
     * 取消每一行的选则框
     * @param rowSelection
     */
    getRowSelection = rowSelection => {
        const sel = {...rowSelection};
        sel.getCheckboxProps = record => {
            return {disabled: record.id === '1'};
        };
    }
    render() {
        const {ispublics = false, columns, datas, store} = this.props;
        const {updateNodeDatas} = store;
        let initialDatas = toJS(datas);
        let columnss = this.getColumnsSelect();
        return (
            <div>
                 <WeaFormItem labelCol={{span: 0}} wrapperCol={{span: 24}}>
                    <WeaTableEditable
                        datas={initialDatas}
                        columns={columnss}
                        // cells={cellss}
                        showTitle={false}
                        onChange={(datas, other) => {updateNodeDatas(datas)}}
                        getRowSelection={this.getRowSelection} //禁用第一列选中框
                    />
                </WeaFormItem>
            </div>
        )
    }

    /**
     * 主要依据是否公有决定相关数据
     */
    getColumnsSelect = () => {
        const {columns, store} = this.props;
        const {ispublics = false} = store;
        let column = [];
        columns && columns.map(item => {
            if(ispublics && item.aboutsevertype) {//公有时排除和公有相关数据
            } else {
                column.push(item);
            }
        });
        return column;
    }
}
export {NodesTable};